<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My Web Application</title>
<meta  name="viewport" content="width=divice-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" />
<link rel="stylesheet" type="text/css" href="../themes/Theme_app.css">
<link rel="stylesheet" type="text/css" href="../themes/jquery.mobile.icons.min.css">
<link rel="stylesheet" type="text/css" href="../themes/Theme_app.min.css">
<link rel="stylesheet" type="text/css" href="../css/Css_Header.css">
<link rel="stylesheet" type="text/css" href="../css/table.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page" id="page">
  <div data-role="header">
    <h1>My Web Application</h1>
  </div>
  <div ><img src="../images/banner.jpg" width="1500" height="100"> </div>
  <div align="center">เว็บแอพพพลิเคชั่นเตรียมพร้อมสอบใบขับขี่รถยนต์ส่วนบุคคล</div>
  <div data-role="content">
    <div data-role="content">
    <ul data-role="listview">       
            <input type="button" id="page4" value="หมวด รูปภาพ เเละ ป้ายจราจร" > 
            </div>	
  
  <div id="d1">
      <form name="form1" method="post" action="ques7.php">

<?
include('../connect/connect.php');
$sql="Select * From Question_4 order by rand() limit 5";
$db_query=mysql_query($sql);
$i=0;
while($result=mysql_fetch_array($db_query))
{
$i++;
?>
        <table width="90%" border="0" align="center">
          <tr>
            <td colspan="3">
                <input name="id[<?=$i;?>]" type="hidden" value="<?=$result["id"];?>">
                <?php echo"$i";  ?> :
                <?=$result["question"];?></td>          
             </tr>
             <tr >
             <td>
             </td>
              <td >
              <img src="../image_quest/<?php echo $result["image"];?>" width="50" height="50"> 
                               
              </td>
             </tr>
             <tr>
              <td width="5px" ><input type="radio" name="c<?=$i;?>" value="1"></td>             
              <td width="90%" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$result["c1"];?></td>
          </tr>
          </tr>
             <tr>
              <td width="5px%" ><input type="radio" name="c<?=$i;?>" value="2"></td>
              <td width="95%" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$result["c2"];?></td>
          </tr>
              <tr>
               <td width="5px"> <input type="radio" name="c<?=$i;?>" value="3"></td>
              <td width="95%" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$result["c3"];?></td>
          </tr>
               <tr>
              <td width="5px"> <input type="radio" name="c<?=$i;?>" value="4"></td>
             <td width="95%" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$result["c4"];?>
              <input name="answer[<?=$i;?>]" type="hidden" value="<?=$result["answer"];?>"></td>
          </tr>
        </table>
        <?
}
mysql_close();
?>
        <div align="center"><br>
        </div>
        <input type="submit" name="Submit" value="ตรวจคะแนน">
        
      </form>
      <?
$score=0;
for($i=1;$i<=count($id);$i++)
{
$ch="c$i";
if($$ch==$answer[$i])
{
$score=$score+1;
}
}

if($score>=4)
{
	echo "&nbsp;&nbspคะแนนเต็ม  5 คะแนน  คะแนนที่ทำได้ $score  คะแนน<br>";
	echo"&nbsp;&nbspผ่านการทดสอบ";
	}
  else 
  {
	  echo "&nbsp;&nbspคะแนนเต็ม  5 คะแนน  คะแนนที่ทำได้ $score  คะแนน<br>";
	  echo"&nbsp;&nbspไม่ผ่านการทดสอบ";
	  }


?>
</div>     
    </ul>
  </div>
  <a href="../page4.php" class="ui-btn ui-icon-back ui-btn-icon-left" data-transition="slide" data-direction="reverse">กลับหน้าเมนูข้อสอบทฤษฏี</a>
  <div data-role="footer">
    <h4>@Computer Science</h4>
  </div>
</div>
</div>
</body>
</html>

